<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreatePurchaseToMaterialsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('purchase_to_materials', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->integer('purchase_id')->index()->nullable()->comment('采购订单ID');
            $table->integer('material_id')->index()->nullable()->comment('材料ID');
            $table->integer('supplier_id')->index()->nullable()->comment('供应商ID');
            $table->integer('number')->index()->nullable()->comment('数量');
            $table->integer('unit_price')->index()->default(0)->comment('单价：单位是分');
            $table->string('description', '255')->nullable()->comment('描述');
            $table->integer('expiration_date')->index()->default(0)->comment('过期时间戳');
            $table->integer('manufacture_date')->index()->default(0)->comment('生产时间戳');
            $table->integer('stock')->index()->default(0)->comment('库存');
            $table->integer('sell')->index()->default(0)->comment('已售');
            $table->integer('status')->index()->default(3)->comment('状态1.正常、2.售馨、3.待采购');
            $table->timestamps();
            $table->softDeletes();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('purchase_to_materials');
    }
}
